home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 38
/
Amiga Format CD38 (1999-03-15)(Future Publishing)(GB)(Track 1 of 3)[!][issue 1999-04].iso
/
-seriously_amiga-
/
misc
/
felix
/
source
/
freshlocale.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1999-01-25
|
3KB
|
134 lines
//*************************************************************************//
// Filename: FreshLocale.cpp
// Autor: Christian Taulien of Strange Intelligence
// Purpose: common localizing Localizing FRESH-Software by SI
// Creation: 31. März 1998
//*************************************************************************//
#include "global.h"
#include "FreshLocale.h"
#include <string.h>
#include <clib/locale_protos.h>
#include <clib/utility_protos.h>
CatalogC *glob_poCatalog = NULL;
CatalogC::CatalogC(char *arg_sName, ULONG arg_ulVersion /*= NULL*/, struct Locale *arg_poLocale /*= NULL*/)
/*S*/
{
m_poCatalog = NULL;
openCatalog(arg_sName, arg_poLocale,
OC_Version, arg_ulVersion,
TAG_DONE);
}
/*E*/
CatalogC::CatalogC(char *arg_sName, struct Locale *arg_poLocale, ULONG arg_eTags ...)
/*S*/
{
m_poCatalog = NULL;
openCatalog(arg_sName, arg_poLocale, (struct TagItem *) &arg_eTags);
}
/*E*/
CatalogC::~CatalogC()
/*S*/
{
closeCatalog();
}
/*E*/
BOOL CatalogC::openCatalog(char *arg_sName, struct Locale *arg_poLocale /*= NULL*/, struct TagItem *arg_poTagList /*= NULL*/)
/*S*/
{
// Schließen, wenn katalog noch offen
closeCatalog();
// einfach versuchen den catalog zu öffnen
m_poCatalog = OpenCatalogA(arg_poLocale, arg_sName, arg_poTagList);
if (m_poCatalog)
{
TRACE("open ok");
}
else
{
TRACE("no open");
} // if
return isOpen();
}
/*E*/
BOOL CatalogC::openCatalog(char *arg_sName, struct Locale *arg_poLocale, ULONG arg_eTags ...)
/*S*/
{
// rufe die richtige methode auf
return openCatalog(arg_sName, arg_poLocale, (struct TagItem *) &arg_eTags);
}
/*E*/
void CatalogC::closeCatalog()
/*S*/
{
TRACE("");
// wenn Catalog überhaupt offen
if (m_poCatalog)
{
CloseCatalog(m_poCatalog);
m_poCatalog = NULL;
} // if
}
/*E*/
char CatalogC::getShortCut(int arg_iStringNum)
/*S*/
{
char *sString = getString(arg_iStringNum);
char cShortCut = '\0';
// wenn string gefunden
if (sString)
{
int iLen = strlen(sString);
for (int i=0; i<iLen; ++i)
{
// wenn underscore gefunden und noch min. ein zeichen danach
// vorhanden
if (sString[i] == '_' && (i < iLen-1))
{
// shortcut gefunden. Schleife verlassen
cShortCut = sString[i+1];
break;
} // if
} // for
} // if
return cShortCut;
}
/*E*/
char CatalogC::getShortCutLowerCase(int arg_iStringNum)
/*S*/
{
return ToLower(getShortCut(arg_iStringNum));
}
/*E*/
unsigned char *CatalogC::getString(int arg_iStringNum)
/*S*/
{
// wenn ungültiger string
if (!(SIFC_BETWEEN(arg_iStringNum, FIRST_POSSIBLE_TEXT, LAST_POSSIBLE_TEXT)
|| SIFC_BETWEEN(arg_iStringNum, FIRST_POSSIBLE_ERROR, LAST_POSSIBLE_ERROR)))
{
arg_iStringNum = T_UNDEFINED;
} // if
// wenn catalog offen
if (m_poCatalog)
{
TRACE("über GetCatalogStr()");
return GetCatalogStr(m_poCatalog, arg_iStringNum, glob_asInternCatalog[arg_iStringNum]);
}
else
{
TRACE("intern");
return glob_asInternCatalog[arg_iStringNum];
} // if
}
/*E*/